//
//  GxBasicViewController.swift
//  microblog
//
//  Created by 记忆不为 on 16/9/17.
//  Copyright © 2016年 记忆不为. All rights reserved.
//

import UIKit

// MARK: - 属性

class GxBasicViewController: UIViewController {

    // MARK: - 控制器方法
    override func loadView() {
        if isLogin {
            self.view = tableView
            tableView.delegate = self
            tableView.dataSource = self
            
        }else{
            
            self.view = visitorView
            
            visitorView.follow = { () ->Void in
                
            }
            if self.isKind(of: GxHomeViewController.self) {
                
                visitorView.setupInfo(title: "关注一些人,回这里看看有什么惊喜")
                
                visitorView.rotationAnimation()
                
                self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(registerDidClick))
                
                self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(loginDidClick))
                
            }else if self.isKind(of: GxMessageViewController.self){
                
                visitorView.setupVisitorInfo(image: "visitordiscover_image_message", title: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
                visitorView.delegate = self
            }else if self.isKind(of: GxDiscoverViewController.self){
                
                visitorView.setupVisitorInfo(image: "visitordiscover_image_message", title: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
                visitorView.delegate = self
                self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(registerDidClick))
                
                self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(loginDidClick))
            }
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    // MARK: - 懒加载
    private lazy var visitorView : GxUnLoginView = GxUnLoginView()
    private lazy var tableView : UITableView = UITableView()
}

extension GxBasicViewController : GxUnLoginViewDelegate{
    
    func registerDidClick() {
        
    }
    func loginDidClick() {
        self.present(UINavigationController(rootViewController: GxOauthViewController()), animated: true, completion: nil)
    }
}

// MARK: - tableView数据源方法
extension GxBasicViewController: UITableViewDataSource,UITableViewDelegate{
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return UITableViewCell()
    }
}
